home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / pas_all.zip / TI134.ASC < prev    next >
Text File  |  1991-09-11  |  2KB  |  67 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.   PRODUCT : TURBO PASCAL                               NUMBER : 134
  10.   VERSION : 3.0xx
  11.        OS : PC-DOS, MS-DOS
  12.      DATE : April 2, 1986                                PAGE : 1/2
  13.     TITLE : RANDOM NUMBER SEED LOCATIONS
  14.  
  15.  
  16.  
  17.  
  18.   Turbo Pascal maintains a four byte random number seed. There is
  19.   a Randomize procedure to give that seed a random value which the
  20.   function, Random, then uses to generate random values within a
  21.   specified range.
  22.  
  23.   Random :  r := seed;
  24.  
  25.   The function Random(value) calls the following routine:
  26.  
  27.   function Random(N_Max): real;
  28.   var c1, c2, r : real;
  29.   begin
  30.     c1 := exp(32 * ln(2));
  31.     c2 := exp(16 * ln(2));
  32.     r  := (r * 129 * $361962E9) mod c1;
  33.     Random := r div c2 mod N_Max;
  34.   end;
  35.  
  36.   The following table gives the random number seed address for most
  37.   Turbo Pascal implementations:
  38.  
  39.   Random Number Seed Locations
  40.  
  41.     IBM TURBO.COM        01FC
  42.     IBM TURBO-87.COM  01FE
  43.     IBM TURBOBCD.COM  0200
  44.     Generic TURBO.COM    01DA
  45.  
  46.   The seed may be declared as:
  47.  
  48.     Var RandomSeed: Array [0..3] Of Byte Absolute DSeg:$01FC;
  49.  
  50.   or:
  51.  
  52.     Var RandomSeed: Array [0..1] Of Integer Absolute DSeg:$01FC;
  53.  
  54.   By replacing the value in the address, you can seed the random
  55.   number generator in any way you like: read it from a file; read a
  56.   number from the user; ask for the user to hit a key, and count
  57.   until he does; get the system time; or, assign a constant value.
  58.   Using constant values is useful in making statistical simulations
  59.   uniform.
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.